package PAT.AdvancedTest;

import org.junit.Test;

import java.util.Scanner;

/**
 * Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).
 * <p>
 * Input
 * <p>
 * Each input file contains one test case. Each case contains a pair of integers a and b where -1000000 <= a, b <= 1000000. The numbers are separated by a space.
 * <p>
 * Output
 * <p>
 * For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.
 * <p>
 * Sample Input
 * -1000000 9
 * Sample Output
 * -999,991
 */
public class NumberFormat {

    public static String formatNumber(Integer number) {

         String str = number.toString();
        StringBuffer result = new StringBuffer();

        if (str.startsWith("-")) {
            result.append("-");
            str = str.substring(1, str.length());
        }

        int mod = (str.length()) % 3;
        if (mod > 0) {
            result.append(str.substring(0, mod));
            result.append(",");
        }

        for (int i = mod; i < str.length() - mod; i = i + 3) {
            result.append(str.substring(i, i + 3));
            result.append(",");
        }

        result.deleteCharAt(result.lastIndexOf(","));

        return result.toString();

    }


//    @Test
//    public void testFormat() {
//
//        System.out.println(formatNumber(-99999));
//        System.out.println(formatNumber(-899344593));
//        System.out.println(formatNumber(899344593));
//    }


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String number = scanner.nextLine();
        int num1 = Integer.parseInt(number.split(" ")[0]);
        int num2 = Integer.parseInt(number.split(" ")[1]);

        System.out.println(formatNumber(num1+num2));


    }
}
